package com.pattern.creational_pattern.builder_pattern;

/**
 * @Description  DIRECTOR: assembling all parts to build the new meal.
 * @Author Ping
 * @Date 2022/3/20 22:49
 **/
public class Waiter {
    private MealBuilder mealBuilder ;

    public Waiter(MealBuilder mealBuilder) {
        this.mealBuilder = mealBuilder;
    }

    public void setMealBuilder(MealBuilder mealBuilder) {
        this.mealBuilder = mealBuilder;
    }

    /**
     * assembling/constructing the meal from parts
     * @return
     */
    public Meal build() {
        // the PROCESS for assembling the meal
        mealBuilder.buildDrink();
        mealBuilder.buildFood();
        return mealBuilder.buildMeal() ;

    }



    public static void main(String args[]) {
        // The application for BUILDER PATTERN
        // client to get a meal from waiter
        // for client, it is easy to build the meal.
        Waiter waiter = new Waiter(new BeefBurgBuilder()) ;
        Meal beefMeal = waiter.build() ;
        System.out.println(beefMeal);
        waiter.setMealBuilder(new ChickenBurgBuilder());
        Meal chickenMeal = waiter.build() ;
//        Meal cloneMeal = chickenMeal.clone() ;
        System.out.println(chickenMeal);


    }
}
